/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lestr.otaf.editeur;

import java.awt.Image;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor;
import org.netbeans.modules.xml.catalog.spi.CatalogListener;
import org.netbeans.modules.xml.catalog.spi.CatalogReader;
import org.openide.util.Utilities;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class RegisterCatalog implements CatalogReader, CatalogDescriptor, EntityResolver {


    public RegisterCatalog() {
    }


    public Iterator getPublicIDs() {

        List<String> list = new ArrayList<String>();

        list.add("SCHEMA:http://www.lestr.org/otaf");
        list.add("SCHEMA:http://www.lestr.org/otaf/es");
        list.add("SCHEMA:http://www.lestr.org/otaf/script");
        list.add("SCHEMA:http://www.lestr.org/otaf/texte");
        list.add("SCHEMA:http://www.lestr.org/otaf/ihm");
        list.add("SCHEMA:http://www.lestr.org/otaf/logique");

        return list.listIterator();

    }


    public void refresh() {
    }


    public String getSystemID(String publicId) {

        if (publicId.equals("SCHEMA:http://www.lestr.org/otaf"))
            return "nbres:/org/lestr/otaf/editeur/xsd/otaf.xsd";

        if (publicId.equals("SCHEMA:http://www.lestr.org/otaf/texte"))
            return "nbres:/org/lestr/otaf/editeur/xsd/otaf-texte.xsd";

        if (publicId.equals("SCHEMA:http://www.lestr.org/otaf/es"))
            return "nbres:/org/lestr/otaf/editeur/xsd/otaf-es.xsd";

        if (publicId.equals("SCHEMA:http://www.lestr.org/otaf/script"))
            return "nbres:/org/lestr/otaf/editeur/xsd/otaf-script.xsd";

        if (publicId.equals("SCHEMA:http://www.lestr.org/otaf/ihm"))
            return "nbres:/org/lestr/otaf/editeur/xsd/otaf-ihm.xsd";

        if (publicId.equals("SCHEMA:http://www.lestr.org/otaf/logique"))
            return "nbres:/org/lestr/otaf/editeur/xsd/otaf-logique.xsd";

        return null;

    }


    public String resolveURI(String string) {
        return null;
    }


    public String resolvePublic(String string) {
        return null;
    }


    public void addCatalogListener(CatalogListener catalogListener) {
    }


    public void removeCatalogListener(CatalogListener catalogListener) {
    }


    public Image getIcon(int i) {
        return Utilities.loadImage("org/lestr/otaf/editeur/icon1.png");
    }


    public String getDisplayName() {
        return "Catalogue OTAF";
    }


    public String getShortDescription() {
        return "Catalogue XML pour OTAF";
    }


    public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
    }


    public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener) {
    }


    public InputSource resolveEntity(String publicId,
                                     String systemId) throws SAXException, IOException {

        if (systemId == null)
            return null;

        if ("http://www.lestr.org/otaf".equals(systemId))
            return new org.xml.sax.InputSource("nbres:/org/lestr/otaf/editeur/xsd/otaf.xsd");

        if ("http://www.lestr.org/otaf/texte".equals(systemId))
            return new org.xml.sax.InputSource("nbres:/org/lestr/otaf/editeur/xsd/otaf-texte.xsd");

        if ("http://www.lestr.org/otaf/ihm".equals(systemId))
            return new org.xml.sax.InputSource("nbres:/org/lestr/otaf/editeur/xsd/otaf-ihm.xsd");

        if ("http://www.lestr.org/otaf/script".equals(systemId))
            return new org.xml.sax.InputSource("nbres:/org/lestr/otaf/editeur/xsd/otaf-script.xsd");

        if ("http://www.lestr.org/otaf/es".equals(systemId))
            return new org.xml.sax.InputSource("nbres:/org/lestr/otaf/editeur/xsd/otaf-es.xsd");

        if ("http://www.lestr.org/otaf/logique".equals(systemId))
            return new org.xml.sax.InputSource("nbres:/org/lestr/otaf/editeur/xsd/otaf-logique.xsd");

        return null;


    }


}